package roborally.model.evaluables.conditions;

import roborally.model.evaluables.Evaluable;
import roborally.model.evaluables.RobotCondition;
import roborally.model.*;

public class CanHitRobot extends RobotCondition implements Evaluable{
	public CanHitRobot(Robot robot) throws IllegalArgumentException {
		super(robot);
	}
	
	/**
	 * @return Returns true if the first field with an element on it in the direction the robot is facing, has another robot on it. If not, false is returned.
	 */
	@Override
	public boolean evaluate(){
		Field field = getRobot().getField().getBoard().getFirstFieldWithElementInDirection(getRobot().getField(), getRobot().getOrientation());
		if( field != null && field.hasRobot() ) return true;
		return false;
	}

}